<template>
  <div class="bk_info" style="padding: 15px" v-loading="isLoading">
    <div class="title">
      填写报卡-{{ name }}
      <span style="float: right">
        <el-button size="small" @click="to_up">返回</el-button>
        <!-- <el-button size="small" type="primary" @click="btn_yes">保存</el-button> -->
        <el-button size="small" type="primary" @click="btn_yes"
          >保存并提交</el-button
        >
      </span>
    </div>
    <div style="margin-top: 70px">
      <el-tabs>
        <el-tab-pane label="报卡信息">
          <p style="font-weight: 700; font-size: 16px; color: #000">报卡信息</p>
          <el-row>
            <el-col :span="12" style="padding: 5px 10px">
              <el-divider content-position="left">基本信息</el-divider>
              <el-form
                ref="form"
                label-width="160px"
                :model="info"
                :rules="rules"
              >
                <el-form-item label="门诊号：">
                  <el-input
                    style="width: 300px"
                    size="small"
                    v-model="info.outPatientNo"
                  ></el-input>
                </el-form-item>
                <el-form-item label="住院号：">
                  <el-input
                    style="width: 300px"
                    size="small"
                    v-model="info.inPatientNo"
                  ></el-input>
                </el-form-item>
                <el-form-item label="姓名：" prop="residentName">
                  <el-input
                    style="width: 300px"
                    size="small"
                    v-model="info.residentName"
                  ></el-input>
                </el-form-item>
                <el-form-item label="性别：" prop="gender">
                  <el-radio-group v-model="info.gender" size="small">
                    <el-radio-button label="1">男</el-radio-button>
                    <el-radio-button label="2">女</el-radio-button>
                    <el-radio-button label="9">未说明的性别</el-radio-button>
                    <el-radio-button label="0">未知的性别</el-radio-button>
                  </el-radio-group>
                </el-form-item>
                <el-form-item label="民族：" prop="national">
                  <el-select
                    v-model="info.national"
                    style="width: 300px"
                    size="small"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="(mzItem, mzIndex) in mzArr"
                      :key="mzIndex"
                      :label="mzItem.name"
                      :value="mzItem.id"
                    >
                    </el-option>
                  </el-select>
                  <!-- <el-input
                        style="width: 300px"
                        size="small"
                        v-model="info.national"
                      ></el-input> -->
                </el-form-item>
                <el-form-item label="国籍：">
                  <el-select
                    v-model="info.natives"
                    style="width: 300px"
                    size="small"
                    placeholder="请选择"
                  >
                    <el-option label="中国" value="中国"> </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="证件类别：" prop="certificateType">
                  <el-select
                    v-model="info.certificateType"
                    style="width: 300px"
                    size="small"
                    placeholder="请选择"
                  >
                    <el-option label="身份证" value="1"> </el-option>
                    <el-option label="护照" value="2"> </el-option>
                    <el-option label="出生证" value="3"> </el-option>
                    <el-option label="户口簿" value="4"> </el-option>
                    <el-option label="其他标识" value="5"> </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="证件号码：" prop="idCard">
                  <el-input
                    style="width: 300px"
                    size="small"
                    v-model="info.idCard"
                    @blur="setDataBirth"
                  ></el-input>
                </el-form-item>
                <el-form-item label="出生日期：" prop="dataBirth">
                  <el-date-picker
                    v-model="info.dataBirth"
                    size="small"
                    type="date"
                    placeholder="选择日期"
                    disabled
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="本人电话：" prop="telephone">
                  <el-input
                    placeholder="请输入内容"
                    size="small"
                    style="width: 300px"
                    v-model="info.telephone"
                  >
                    <template slot="prepend">+86</template>
                  </el-input>
                </el-form-item>
                <el-form-item label="医保类型：">
                  <el-select
                    v-model="info.healthType"
                    style="width: 300px"
                    size="small"
                    placeholder="请选择"
                  >
                    <el-option label="职工医保" value="1"> </el-option>
                    <el-option label="居民医保" value="0"> </el-option>
                    <el-option label="其他医疗保障" value="3"> </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item
                  label="现住址居住6个月以上"
                  prop="isResideSixMonth"
                >
                  <el-radio-group v-model="info.isResideSixMonth" size="small">
                    <el-radio-button :label="true">是</el-radio-button>
                    <el-radio-button :label="false">否</el-radio-button>
                  </el-radio-group>
                </el-form-item>
                <el-form-item label="现住地址：" prop="nowAddress">
                  <!-- <el-input
                    style="width: 500px"
                    size="small"
                    v-model="info.nowAddress"
                  ></el-input> -->
                  <el-select
                    v-model="info.nowAddress1"
                    filterable
                    size="small"
                    placeholder="请选择省"
                    style="display: inline-block; width: 100px"
                    @change="get市($event)"
                  >
                    <el-option
                      style="width: 100px"
                      v-for="item in 省"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                  <el-select
                    v-model="info.nowAddress2"
                    filterable
                    size="small"
                    placeholder="请选择市"
                    style="display: inline-block; width: 100px"
                    @change="get县($event)"
                  >
                    <el-option
                      style="width: 100px"
                      v-for="item in 市"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                  <el-select
                    v-model="info.nowAddress3"
                    filterable
                    size="small"
                    placeholder="请选择县"
                    style="display: inline-block; width: 100px"
                    @change="get乡($event)"
                  >
                    <el-option
                      style="width: 100px"
                      v-for="item in 县"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                  <el-select
                    v-model="info.nowAddress4"
                    filterable
                    size="small"
                    placeholder="请选择乡"
                    style="display: inline-block; width: 100px"
                    @change="get村($event)"
                  >
                    <el-option
                      style="width: 100px"
                      v-for="item in 乡"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                  <el-select
                    v-model="info.nowAddress5"
                    filterable
                    size="small"
                    placeholder="请选择村"
                    style="display: inline-block; width: 100px"
                  >
                    <el-option
                      style="width: 100px"
                      v-for="item in 村"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                  <el-input
                    placeholder="住址"
                    size="small"
                    style="width: 100px"
                    v-model="info.nowAddress6"
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="户籍地址：" prop="permanentAddress">
                  <!-- <el-input
                    style="width: 500px"
                    size="small"
                    v-model="info.nowAddress"
                  ></el-input> -->
                  <el-select
                    v-model="info.permanentAddress1"
                    filterable
                    size="small"
                    placeholder="请选择省"
                    style="display: inline-block; width: 100px"
                    @change="get市($event)"
                  >
                    <el-option
                      style="width: 100px"
                      v-for="item in 省"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                  <el-select
                    v-model="info.permanentAddress2"
                    filterable
                    size="small"
                    placeholder="请选择市"
                    style="display: inline-block; width: 100px"
                    @change="get县($event)"
                  >
                    <el-option
                      style="width: 100px"
                      v-for="item in 市"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                  <el-select
                    v-model="info.permanentAddress3"
                    filterable
                    size="small"
                    placeholder="请选择县"
                    style="display: inline-block; width: 100px"
                    @change="get乡($event)"
                  >
                    <el-option
                      style="width: 100px"
                      v-for="item in 县"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                  <el-select
                    v-model="info.permanentAddress4"
                    filterable
                    size="small"
                    placeholder="请选择乡"
                    style="display: inline-block; width: 100px"
                    @change="get村($event)"
                  >
                    <el-option
                      style="width: 100px"
                      v-for="item in 乡"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                  <el-select
                    v-model="info.permanentAddress5"
                    filterable
                    size="small"
                    placeholder="请选择村"
                    style="display: inline-block; width: 100px"
                  >
                    <el-option
                      style="width: 100px"
                      v-for="item in 村"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    >
                    </el-option>
                  </el-select>
                  <el-input
                    placeholder="住址"
                    size="small"
                    style="width: 100px"
                    v-model="info.permanentAddress6"
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="文化程度：">
                  <el-select
                    v-model="info.education"
                    style="width: 300px"
                    size="small"
                    placeholder="请选择"
                  >
                    <el-option label="研究生" value="1"> </el-option>
                    <el-option label="大学本科" value="2"> </el-option>
                    <el-option label="大学专科和专科学院" value="3">
                    </el-option>
                    <el-option label="中等专业学校" value="4"> </el-option>
                    <el-option label="技工学校" value="5"> </el-option>
                    <el-option label="高中" value="6"> </el-option>
                    <el-option label="初中" value="7"> </el-option>
                    <el-option label="小学" value="8"> </el-option>
                    <el-option label="文盲或半文盲" value="9"> </el-option>
                    <el-option label="不详" value="10"> </el-option>
                    <el-option label="硕士" value="11"> </el-option>
                    <el-option label="博士" value="12"> </el-option>
                  </el-select>
                  <!-- <el-input
                        style="width: 500px"
                        size="small"
                        v-model="info.education"
                      ></el-input> -->
                </el-form-item>
                <el-form-item label="工作单位：">
                  <el-input
                    style="width: 300px"
                    size="small"
                    v-model="info.workUnit"
                  ></el-input>
                </el-form-item>
                <el-form-item label="联系人：" prop="contactName">
                  <el-input
                    style="width: 300px"
                    size="small"
                    v-model="info.contactName"
                  ></el-input>
                </el-form-item>
                <el-form-item label="联系人电话：" prop="contactPhone">
                  <el-input
                    placeholder="请输入内容"
                    size="small"
                    style="width: 300px"
                    v-model="info.contactPhone"
                  >
                    <template slot="prepend">+86</template>
                  </el-input>
                </el-form-item>
                <el-form-item label="与患者关系：">
                  <!-- <el-select
                      v-model="info.yhzgx"
                      style="width: 300px"
                      size="small"
                      placeholder="请选择"
                    >
                      <el-option label="测试数据" value="测试数据"> </el-option>
                    </el-select> -->
                  <el-input
                    style="width: 300px"
                    size="small"
                    v-model="info.relationship"
                  ></el-input>
                </el-form-item>
                <el-form-item label="备注：">
                  <el-input
                    type="textarea"
                    :autosize="{ minRows: 4, maxRows: 6 }"
                    placeholder="请输入内容"
                    v-model="info.remark"
                    size="small"
                    style="width: 500px"
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="婚姻状况">
                  <el-radio-group v-model="info.maritalStatus" size="small">
                    <el-radio-button label="1">未婚</el-radio-button>
                    <el-radio-button label="2">已婚/再婚/同居</el-radio-button>
                    <el-radio-button label="3">分居</el-radio-button>
                    <el-radio-button label="4">离异</el-radio-button>
                    <el-radio-button label="5">丧偶</el-radio-button>
                  </el-radio-group>
                </el-form-item>
                <el-form-item label="职业：">
                  <el-select
                    v-model="info.duty"
                    style="width: 300px"
                    size="small"
                    placeholder="请选择"
                  >
                    <el-option
                      label="国家机关、党群组织、企业、事业单位责任人"
                      value="1"
                    >
                    </el-option>
                    <el-option label="专业技术人员" value="2"> </el-option>
                    <el-option label="办事人员和有关人员" value="3">
                    </el-option>
                    <el-option label="商业、服务业人员" value="4"> </el-option>
                    <el-option
                      label="生产、运输设备操作人员及有关人员"
                      value="5"
                    >
                    </el-option>
                    <el-option label="军人" value="6"> </el-option>
                    <el-option label="不便分类的其他从业人员" value="7">
                    </el-option>
                    <el-option label="无职业" value="8"> </el-option>
                  </el-select>
                  <!-- <el-input
                        style="width: 300px"
                        size="small"
                        v-model="info.duty"
                      ></el-input> -->
                </el-form-item>
                <el-divider content-position="left">患病信息</el-divider>
                <el-form-item label="ICD码：">
                  <el-select
                    v-model="hb_info.icd"
                    filterable
                    placeholder="请选择icd码"
                    style="width: 300px"
                    size="small"
                  >
                    <el-option
                      v-for="item in icd_arr"
                      :key="item.Code"
                      :label="item.Diagnose"
                      :value="item.Code"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="收缩压">
                  <el-input
                    placeholder="请输入内容"
                    size="small"
                    style="width: 500px"
                    v-model="hb_info.sbp"
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="舒张压">
                  <el-input
                    placeholder="请输入内容"
                    size="small"
                    style="width: 500px"
                    v-model="hb_info.dbp"
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="诊断类型：">
                  <el-select
                    v-model="hb_info.icdType"
                    style="width: 300px"
                    size="small"
                    placeholder="请选择"
                  >
                    <el-option label="初诊" value="初诊"> </el-option>
                    <el-option label="复诊" value="复诊"> </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="慢性肾脏病分期：">
                  <el-checkbox-group v-model="hb_info.category">
                    <el-checkbox label="G1"></el-checkbox><br />
                    <el-checkbox label="G2"></el-checkbox><br />
                    <el-checkbox label="G3a"></el-checkbox><br />
                    <el-checkbox label="G3b"></el-checkbox><br />
                    <el-checkbox label="G4"></el-checkbox><br />
                    <el-checkbox label="G5"></el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
                <el-form-item label="eGFR：">
                  <el-input
                    placeholder="请输入内容"
                    size="small"
                    style="width: 200px"
                    v-model="hb_info.eGFR"
                  >
                  </el-input>
                  ml/（min·1.73㎡）
                </el-form-item>
                <el-form-item label="报卡单位：">
                  <el-input
                    placeholder="请输入内容"
                    size="small"
                    style="width: 500px"
                    v-model="info.bkHosiptalName"
                    disabled
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="报告科室：">
                  <el-input
                    placeholder="请输入内容"
                    size="small"
                    style="width: 500px"
                    v-model="info.bkSectionName"
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="报告医生：">
                  <el-input
                    placeholder="请输入内容"
                    size="small"
                    style="width: 500px"
                    v-model="info.bkDoctorName"
                    disabled
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="报卡日期：">
                  <el-date-picker
                    v-model="info.bkTime"
                    size="small"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-form>
            </el-col>
            <el-col :span="12" style="padding: 5px 10px" v-if="user_info">
              <el-divider content-position="left"
                >居民健康档案参考信息</el-divider
              >
              <div class="ckxx">
                <p>
                  <span
                    style="
                      display: inline-block;
                      width: 15%;
                      font-size: 20px;
                      font-weight: 900;
                      color: #000;
                    "
                    >{{ user_info.residentName }}</span
                  >
                  {{ user_info.gender | gender }}
                  {{ user_info.duty | duty }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%"
                    >出生日期</span
                  >
                  {{ user_info.dataBirth }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%"
                    >证件类型</span
                  >
                  {{ user_info.certificateType | certificateType }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%"
                    >证件号码</span
                  >
                  {{ user_info.idCard }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%"
                    >本人电话</span
                  >
                  {{ user_info.telephone }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%"
                    >联系人姓名</span
                  >
                  {{ user_info.contactName }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%"
                    >联系人电话</span
                  >
                  {{ user_info.contactPhone }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%"
                    >常住类型</span
                  >
                  {{ user_info.usualType | usualType }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%">民族</span>
                  {{ user_info.national | national }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%"
                    >户籍地址</span
                  >
                  {{ user_info.permanentAddress }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%">现住址</span>
                  {{ user_info.nowAddress }}
                </p>
                <p>
                  <span style="display: inline-block; width: 15%"
                    >工作单位</span
                  >
                  {{ user_info.workUnit }}
                </p>
              </div>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="操作记录">
          <el-timeline>
            <el-timeline-item
              color="rgb(46,160,254)"
              timestamp=""
              placement="top"
            >
              <el-card>
                <p style="margin-bottom: 0">暂无记录</p>
              </el-card>
            </el-timeline-item>
          </el-timeline>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>
      
      <script>
export default {
  data() {
    return {
      name: "",
      info: {
        residentName: "",
        gender: "",
        certificateType: "",
        idCard: "",
        nowAddress: "",
        hospitalId: "",
        chronicType: "",
        outPatientNo: "",
        inPatientNo: "",
        national: "",
        natives: "",
        dataBirth: "",
        telephone: "",
        healthType: "",
        isResideSixMonth: "",
        permanentAddress: "",
        education: "",
        workUnit: "",
        contactName: "",
        contactPhone: "",
        relationship: "",
        remark: "",
        maritalStatus: "",
        duty: "",
        bkHosiptalId: "",
        bkHosiptalName: "",
        bkDoctorId: "",
        bkDoctorName: "",
        bkTime: "",
        zdHosiptalId: "",
        zdHosiptalName: "",
        zdHosiptalLevel: "",
        returnType: "",
        bkSectionName: "",
      },
      hb_info: {
        glu: "",
        icd: "",
        icdType: "",
        testType: "",
        testDate: "",
        concomitant: "",
        complication: "",
        category: [],
      },
      icd_arr: [],
      user_info: {},
      mzArr: [
        { name: "汉族", id: "1" },
        { name: "苗族", id: "2" },
        { name: "回族", id: "3" },
        { name: "壮族", id: "4" },
        { name: "满族", id: "5" },
        { name: "白族", id: "6" },
        { name: "蒙古族", id: "7" },
        { name: "维吾尔族", id: "8" },
        { name: "土家族", id: "9" },
        { name: "傣族", id: "10" },
        { name: "彝族", id: "11" },
        { name: "藏族", id: "12" },
        { name: "黎族", id: "13" },
        { name: "怒族", id: "14" },
        { name: "景颇族", id: "15" },
        { name: "朝鲜族", id: "16" },
        { name: "土族", id: "17" },
        { name: "门巴族", id: "18" },
        { name: "水族", id: "19" },
        { name: "毛南族", id: "20" },
        { name: "乌孜别克族", id: "21" },
        { name: "布依族", id: "22" },
        { name: "布朗族", id: "23" },
        { name: "东乡族", id: "24" },
        { name: "仡佬族", id: "25" },
        { name: "仫佬族", id: "26" },
        { name: "达斡尔族", id: "27" },
        { name: "佤族", id: "28" },
        { name: "羌族", id: "29" },
        { name: "阿昌族", id: "30" },
        { name: "纳西族", id: "31" },
        { name: "拉祜族", id: "32" },
        { name: "侗族", id: "33" },
        { name: "京族", id: "34" },
        { name: "柯尔克孜族", id: "35" },
        { name: "哈尼族", id: "36" },
        { name: "哈萨克族", id: "37" },
        { name: "保安族", id: "38" },
        { name: "俄罗斯族", id: "39" },
        { name: "独龙族", id: "40" },
        { name: "珞巴族", id: "41" },
        { name: "高山族", id: "42" },
        { name: "基诺族", id: "43" },
        { name: "鄂伦春族", id: "44" },
        { name: "鄂温克族", id: "45" },
        { name: "塔吉克族", id: "46" },
        { name: "塔塔尔族", id: "47" },
        { name: "傈僳族", id: "48" },
        { name: "畲族", id: "49" },
        { name: "普米族", id: "50" },
        { name: "裕固族", id: "51" },
        { name: "锡伯族", id: "52" },
        { name: "瑶族", id: "53" },
        { name: "赫哲族", id: "54" },
        { name: "撒拉族", id: "55" },
        { name: "德昂族", id: "56" },
        { name: "果敢族", id: "57" },
        { name: "摩梭人", id: "58" },
        { name: "穿青人族", id: "59" },
        { name: "其他民族", id: "60" },
      ],
      isLoading: false,
      rules: {
        residentName: [
          { required: true, message: "请输入姓名", trigger: "blur" },
        ],
        gender: [{ required: true, message: "请选择性别", trigger: "change" }],
        national: [
          { required: true, message: "请选择民族", trigger: "change" },
        ],
        certificateType: [
          { required: true, message: "请选择民族", trigger: "change" },
        ],
        idCard: [
          { required: true, message: "请输入证件号码", trigger: "blur" },
        ],
        dataBirth: [
          { required: true, message: "请选择出生日期", trigger: "change" },
        ],
        telephone: [
          { required: true, message: "请输入本人电话号", trigger: "blur" },
        ],
        isResideSixMonth: [
          {
            required: true,
            message: "请选择现住址居住6个月以上标识",
            trigger: "change",
          },
        ],
        // nowAddress1: [
        //   { required: true, message: "请输入现住地址", trigger: "change" },
        // ],
        // permanentAddress1: [
        //   { required: true, message: "请输入户籍地址", trigger: "change" },
        // ],
        contactName: [
          { required: true, message: "请填写联系人", trigger: "blur" },
        ],
        contactPhone: [
          { required: true, message: "请填写联系人电话", trigger: "blur" },
        ],
      },
      省: [],
      省_value: "",
      市: [],
      市_value: "",
      县: [],
      县_value: "",
      乡: [],
      乡_value: "",
      村: [],
      村_value: "",
    };
  },
  mounted() {
    this.isLoading = true;
    this.name = this.$route.query.name;
    this.get省();
    this.getIcd(this.name);
    this.getUserInfoByIdCard(this.$route.query.idCard);
    this.setFormInfo();
  },
  filters: {
    gender(val) {
      var str = "";
      if (val == 1) {
        str = "男";
      }
      if (val == 2) {
        str = "女";
      }
      if (val == 9) {
        str = "未知的性别";
      }
      if (val == 0) {
        str = "未说明的性别";
      }
      return str;
    },
    duty(val) {
      var str = "";
      if (val == 1) {
        str = "国家机关、党群组织、企业、事业单位责任人";
      }
      if (val == 2) {
        str = "专业技术人员";
      }
      if (val == 3) {
        str = "办事人员和有关人员";
      }
      if (val == 4) {
        str = "商业、服务业人员";
      }
      if (val == 5) {
        str = "生产、运输设备操作人员及有关人员";
      }
      if (val == 6) {
        str = "军人";
      }
      if (val == 7) {
        str = "不便分类的其他从业人员";
      }
      if (val == 8) {
        str = "无职业";
      }
      return str;
    },
    certificateType(val) {
      var str = "";
      if (val == 1) {
        str = "身份证";
      }
      if (val == 2) {
        str = "护照";
      }
      if (val == 3) {
        str = "出生证";
      }
      if (val == 4) {
        str = "户口簿";
      }
      if (val == 5) {
        str = "其他标识";
      }
      return str;
    },
    usualType(val) {
      var str = "";
      if (val == 0) {
        str = "其他";
      }
      if (val == 1) {
        str = "户籍";
      }
      if (val == 2) {
        str = "非户籍";
      }
      return str;
    },
    national(val) {
      var mz = "";
      if (val == 1) {
        mz = "汉族";
        return mz;
      }
      if (val == 2) {
        mz = "苗族";
        return mz;
      }
      if (val == 3) {
        mz = "回族";
        return mz;
      }
      if (val == 4) {
        mz = "壮族";
        return mz;
      }
      if (val == 5) {
        mz = "满族";
        return mz;
      }
      if (val == 6) {
        mz = "白族";
        return mz;
      }
      if (val == 7) {
        mz = "蒙古族";
        return mz;
      }
      if (val == 8) {
        mz = "维吾尔族";
        return mz;
      }
      if (val == 9) {
        mz = "土家族";
        return mz;
      }
      if (val == 10) {
        mz = "傣族";
        return mz;
      }
      if (val == 11) {
        mz = "彝族";
        return mz;
      }
      if (val == 12) {
        mz = "藏族";
        return mz;
      }
      if (val == 13) {
        mz = "黎族";
        return mz;
      }
      if (val == 14) {
        mz = "怒族";
        return mz;
      }
      if (val == 15) {
        mz = "景颇族";
        return mz;
      }
      if (val == 16) {
        mz = "朝鲜族";
        return mz;
      }
      if (val == 17) {
        mz = "土族";
        return mz;
      }
      if (val == 18) {
        mz = "门巴族";
        return mz;
      }
      if (val == 19) {
        mz = "水族";
        return mz;
      }
      if (val == 20) {
        mz = "毛南族";
        return mz;
      }
      if (val == 21) {
        mz = "乌孜别克族";
        return mz;
      }
      if (val == 22) {
        mz = "布依族";
        return mz;
      }
      if (val == 23) {
        mz = "布朗族";
        return mz;
      }
      if (val == 24) {
        mz = "东乡族";
        return mz;
      }
      if (val == 25) {
        mz = "仡佬族";
        return mz;
      }
      if (val == 26) {
        mz = "仫佬族";
        return mz;
      }
      if (val == 27) {
        mz = "达斡尔族";
        return mz;
      }
      if (val == 28) {
        mz = "佤族";
        return mz;
      }
      if (val == 29) {
        mz = "羌族";
        return mz;
      }
      if (val == 30) {
        mz = "阿昌族";
        return mz;
      }
      if (val == 31) {
        mz = "纳西族";
        return mz;
      }
      if (val == 32) {
        mz = "拉祜族";
        return mz;
      }
      if (val == 33) {
        mz = "侗族";
        return mz;
      }
      if (val == 34) {
        mz = "京族";
        return mz;
      }
      if (val == 35) {
        mz = "柯尔克孜族";
        return mz;
      }
      if (val == 36) {
        mz = "哈尼族";
        return mz;
      }
      if (val == 37) {
        mz = "哈萨克族";
        return mz;
      }
      if (val == 38) {
        mz = "保安族";
        return mz;
      }
      if (val == 39) {
        mz = "俄罗斯族";
        return mz;
      }
      if (val == 40) {
        mz = "独龙族";
        return mz;
      }
      if (val == 41) {
        mz = "珞巴族";
        return mz;
      }
      if (val == 42) {
        mz = "高山族";
        return mz;
      }
      if (val == 43) {
        mz = "基诺族";
        return mz;
      }
      if (val == 44) {
        mz = "鄂伦春族";
        return mz;
      }
      if (val == 45) {
        mz = "鄂温克族";
        return mz;
      }
      if (val == 46) {
        mz = "塔吉克族";
        return mz;
      }
      if (val == 47) {
        mz = "塔塔尔族";
        return mz;
      }
      if (val == 48) {
        mz = "傈僳族";
        return mz;
      }
      if (val == 49) {
        mz = "畲族";
        return mz;
      }
      if (val == 50) {
        mz = "普米族";
        return mz;
      }
      if (val == 51) {
        mz = "裕固族";
        return mz;
      }
      if (val == 52) {
        mz = "锡伯族";
        return mz;
      }
      if (val == 53) {
        mz = "瑶族";
        return mz;
      }
      if (val == 54) {
        mz = "赫哲族";
        return mz;
      }
      if (val == 55) {
        mz = "撒拉族";
        return mz;
      }
      if (val == 56) {
        mz = "德昂族";
        return mz;
      }
      if (val == 57) {
        mz = "果敢族";
        return mz;
      }
      if (val == 58) {
        mz = "摩梭人";
        return mz;
      }
      if (val == 59) {
        mz = "穿青人族";
        return mz;
      }
      if (val == 60) {
        mz = "其他民族";
        return mz;
      }
    },
  },
  methods: {
    to_up() {
      this.$router.push("/BKXT/add/addCard");
    },
    getIcd(name) {
      this.$get(
        baseUrl.mbIp +
          "/api/NGroupDiagnose/GetNGroupDiagnoseBySymptomName/" +
          name
      ).then((res) => {
        this.icd_arr = res.Data;
      });
    },
    getUserInfoByIdCard(idCard) {
      this.$post("/resident/getInfoByIdCard?idCard=" + idCard).then((res) => {
        this.user_info = res.data;
        if (res.data) {
          this.setUserInfo();
        }
      });
    },
    setFormInfo() {
      this.info.bkHosiptalName = window.localStorage.getItem("hospitalName");
      this.info.bkHosiptalId = window.localStorage.getItem("hospitalId");
      this.info.bkDoctorId = window.localStorage.getItem("doctorId");
      this.info.bkDoctorName = window.localStorage.getItem("doctorName");
      this.info.bkTime = this.time(new Date());
      this.info.natives = "中国";
      this.isLoading = false;
    },
    time(val) {
      if (val == null || val == "") {
        return "";
      } else {
        let d = new Date(val); // val 为表格内取到的后台时间
        let month =
          d.getMonth() + 1 < 10 ? "0" + (d.getMonth() + 1) : d.getMonth() + 1;
        let day = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
        let hours = d.getHours() < 10 ? "0" + d.getHours() : d.getHours();
        let min = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
        let sec = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds();
        let times = d.getFullYear() + "-" + month + "-" + day;
        return times;
      }
    },
    setUserInfo() {
      this.info.residentName = this.user_info.residentName;
      this.info.gender = this.user_info.gender;
      this.info.national = this.user_info.national;
      this.info.certificateType = this.user_info.certificateType;
      this.info.idCard = this.user_info.idCard;
      this.info.dataBirth = this.user_info.dataBirth;
      this.info.telephone = this.user_info.telephone;
      this.info.healthType = this.user_info.healthType;
      this.info.nowAddress = this.user_info.nowAddress;
      this.info.permanentAddress = this.user_info.permanentAddress;
      this.info.education = this.user_info.education;
      this.info.workUnit = this.user_info.workUnit;
      this.info.contactName = this.user_info.contactName;
      this.info.contactPhone = this.user_info.contactPhone;
      this.info.relationship = this.user_info.relationship;
      this.info.remark = this.user_info.remark;
      this.info.maritalStatus = this.user_info.maritalStatus;
      this.info.duty = this.user_info.duty;
      this.info.isResideSixMonth = true;
      this.setDataBirth();
      this.setUser_His();
    },
    setUser_His() {
      this.$get(
        baseUrl.mbIp +
          "/api/His/GetHisPatientInfoByIdCard/" +
          this.$route.query.idCard
      ).then((res) => {
        if (res.Data) {
          this.info.outPatientNo = res.Data.门诊号;
          this.info.inPatientNo = res.Data.住院号;
          this.info.sbp = res.Data.低压;
          this.info.dbp = res.Data.高压;
          this.hb_info.icdType = res.Data.初诊;
        } else {
          this.$notify.error({
            title: "提示",
            message: "获取HIS信息失败！",
          });
        }
      });
    },
    btn_yes() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.isLoading = true;
          this.hb_info.category = this.hb_info.category.join(",");
          var body = {
            master: this.info,
            child: this.hb_info,
          };
          var that = this;
          this.$post("/mbBkMxszb/insert", body).then((res) => {
            that.isLoading = false;
            if (res.code != 200) {
              that.$notify.error({
                title: "错误",
                message: res.message,
              });
            } else {
              that.$notify({
                title: "成功",
                message: "操作成功",
                type: "success",
              });
              setTimeout((_) => {
                that.$router.push("/BKJS");
              }, 100);
            }
          });
        } else {
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs["form"].resetFields();
    },
    get省() {
      this.$get(baseUrl.hrIp + "/auth/organs/getRegion?id=1").then((res) => {
        this.省 = res.data;
      });
    },
    get市(val) {
      var id = "";
      for (var i in this.省) {
        if (this.省[i].name == val) {
          id = this.省[i].id;
        }
      }
      this.$get(baseUrl.hrIp + "/auth/organs/getRegion?id=" + id).then(
        (res) => {
          this.市 = res.data;
        }
      );
    },
    get县(val) {
      var id = "";
      for (var i in this.市) {
        if (this.市[i].name == val) {
          id = this.市[i].id;
        }
      }
      this.$get(baseUrl.hrIp + "/auth/organs/getRegion?id=" + id).then(
        (res) => {
          this.县 = res.data;
        }
      );
    },
    get乡(val) {
      var id = "";
      for (var i in this.县) {
        if (this.县[i].name == val) {
          id = this.县[i].id;
        }
      }
      this.$get(baseUrl.hrIp + "/auth/organs/getRegion?id=" + id).then(
        (res) => {
          this.乡 = res.data;
        }
      );
    },
    get村(val) {
      var id = "";
      for (var i in this.乡) {
        if (this.乡[i].name == val) {
          id = this.乡[i].id;
        }
      }
      this.$get(baseUrl.hrIp + "/auth/organs/getRegion?id=" + id).then(
        (res) => {
          this.村 = res.data;
        }
      );
    },
    idCard(userCard, num) {
      //获取出生日期
      var birth;
      if (num == 1) {
        birth =
          userCard.substring(6, 10) +
          "-" +
          userCard.substring(10, 12) +
          "-" +
          userCard.substring(12, 14);
        return birth;
      }
      //获取性别
      if (num == 2) {
        if (parseInt(userCard.substr(16, 1)) % 2 == 1) {
          return "男";
        } else {
          return "女";
        }
      }
      //获取年龄
      if (num == 3) {
        var myDate = new Date();
        var month = myDate.getMonth() + 1;
        var day = myDate.getDate();
        var age = myDate.getFullYear() - userCard.substring(6, 10) - 1;
        if (
          userCard.substring(10, 12) < month ||
          (userCard.substring(10, 12) == month &&
            userCard.substring(12, 14) <= day)
        ) {
          age++;
        }
        return age;
      }
    },
    setDataBirth() {
      if (!this.info.idCard) {
        return;
      }
      var IDCard = this.info.idCard;
      this.info.dataBirth = this.idCard(IDCard, 1);
    },
  },
};
</script>
      
      <style scoped lang="scss">
.bk_info {
  background-color: #fff;
  height: calc(100vh - 46px);
  overflow: auto;
  .title {
    position: fixed;
    width: calc(100% - 55px);
    z-index: 99;
    top: 45px;
    background-color: #fff;
    font-size: 24px;
    font-weight: 900;
    color: #000;
    padding: 20px;
    border: 1px solid #ccc;
  }
}
.el-form-item {
  margin-bottom: 5px;
}
.ckxx {
  background-color: rgb(238, 238, 238);
  border: 1px solid #ccc;
  padding: 35px;
  border-radius: 5px;
}
::v-deep .el-form-item__error {
  color: #f56c6c;
  font-size: 12px;
  line-height: 1;
  padding-top: 4px;
  position: absolute;
  top: -13px;
  left: 0;
}
</style>